package com.ruoyi.web.controller.system.statis.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.statis.domain.ServiceStatisSale;
import com.ruoyi.system.statis.service.IServiceStatisSaleService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 销售统计Controller
 * 
 * @author Administrator
 * @date 2021-03-06
 */
@Controller
@RequestMapping("/statis/sale")
public class ServiceStatisSaleController extends BaseController
{
    private String prefix = "statis/sale";

    @Autowired
    private IServiceStatisSaleService serviceStatisSaleService;

    @RequiresPermissions("statis:sale:view")
    @GetMapping()
    public String sale()
    {
        return prefix + "/sale";
    }

    /**
     * 查询销售统计列表
     */
    @RequiresPermissions("statis:sale:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ServiceStatisSale serviceStatisSale)
    {
        startPage();
        List<ServiceStatisSale> list = serviceStatisSaleService.selectServiceStatisSaleList(serviceStatisSale);
        return getDataTable(list);
    }

    /**
     * 导出销售统计列表
     */
    @RequiresPermissions("statis:sale:export")
    @Log(title = "销售统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ServiceStatisSale serviceStatisSale)
    {
        List<ServiceStatisSale> list = serviceStatisSaleService.selectServiceStatisSaleList(serviceStatisSale);
        ExcelUtil<ServiceStatisSale> util = new ExcelUtil<ServiceStatisSale>(ServiceStatisSale.class);
        return util.exportExcel(list, "sale");
    }

    /**
     * 新增销售统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存销售统计
     */
    @RequiresPermissions("statis:sale:add")
    @Log(title = "销售统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ServiceStatisSale serviceStatisSale)
    {
        return toAjax(serviceStatisSaleService.insertServiceStatisSale(serviceStatisSale));
    }

    /**
     * 修改销售统计
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ServiceStatisSale serviceStatisSale = serviceStatisSaleService.selectServiceStatisSaleById(id);
        mmap.put("serviceStatisSale", serviceStatisSale);
        return prefix + "/edit";
    }

    /**
     * 修改保存销售统计
     */
    @RequiresPermissions("statis:sale:edit")
    @Log(title = "销售统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ServiceStatisSale serviceStatisSale)
    {
        return toAjax(serviceStatisSaleService.updateServiceStatisSale(serviceStatisSale));
    }

    /**
     * 删除销售统计
     */
    @RequiresPermissions("statis:sale:remove")
    @Log(title = "销售统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(serviceStatisSaleService.deleteServiceStatisSaleByIds(ids));
    }
}
